package com.recSys.model;

/**
 * Created by dell on 2017/8/8.
 */
public class UserOrgBehavior {

    private int userID;

    private int orgID;

    private Double rating;

    private int collect; //1：收藏 0：未收藏

    private int viewTimes; //浏览次数

    private double overallRating; //加权综合评分

    public int getUserID() {
        return userID;
    }

    public void setUserID(int userID) {
        this.userID = userID;
    }

    public int getOrgID() {
        return orgID;
    }

    public void setOrgID(int orgID) {
        this.orgID = orgID;
    }

    public Double getRating() {
        if(this.rating != null)
            return rating;
        else
            return 0.0;
    }

    public void setRating(Double rating) {
        this.rating = rating;
    }

    public int getCollect() {
        return collect;
    }

    public void setCollect(int collect) {
        this.collect = collect;
    }

    public int getViewTimes() {
        return viewTimes;
    }

    public void setViewTimes(int viewTimes) {
        this.viewTimes = viewTimes;
    }

    public double getOverallRating(UserOrgBehavior uob) {
        this.overallRating = uob.getRating() + uob.getCollect() * 0.5;
        return overallRating;
    }

    public void setOverallRating(double overallRating) {
        this.overallRating = overallRating;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        UserOrgBehavior that = (UserOrgBehavior) o;

        if (getUserID() != that.getUserID()) return false;
        return getOrgID() == that.getOrgID();
    }

    @Override
    public int hashCode() {
        int result = getUserID();
        result = 31 * result + getOrgID();
        return result;
    }
}
